package simulacao;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import simulacao.util.thread.ThreadEscrita;
import simulacao.util.SaidaPersonalizada;

/**
 * @author Marcello Willians
 */
public-read def simulationLoop: Timeline = Timeline {
            repeatCount: Timeline.INDEFINITE
            keyFrames: [
                KeyFrame {
                    time: Config.REFRESH_RATE
                    action: function () {
                        SimulationCore.simulationUpdate();
                    }
                }
            ]
}

public var threadEscrita : ThreadEscrita = new ThreadEscrita(SaidaPersonalizada.saida);

function run() {
    Stage {
        title: "Simulação de Trânsito 2.0"
        width: Config.SCREEN_WIDTH;
        height: Config.SCREEN_HEIGHT;
        resizable: false
        onClose: function () {
            threadEscrita.stop();
            FX.exit();
        }
        scene: Scene {
            content: [
                SimulationView {}
            ]
        }
    }
}
